package com.seguriapp.entities;

import java.util.LinkedHashMap;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.seguriapp.base.BaseEntity;

/**
 * Represents a Procedure entity.
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
@Entity
@Table(name = "PaperworkAttribute")
public class PaperworkAttribute extends BaseEntity {

  private static final long serialVersionUID = -334277024854192068L;

  @Id
  @GeneratedValue
  private Long id;

  @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
  @JoinColumn(nullable = false, name = "paperworkId")
  private Paperwork paperwork;

  @Enumerated(EnumType.STRING)
  private PaperworkAttributeCode code;

  private String value;

  public Long getId() {
    return id;
  }

  public void setId(final Long id) {
    this.id = id;
  }

  public Paperwork getPaperwork() {
    return paperwork;
  }

  public void setPaperwork(final Paperwork paperwork) {
    this.paperwork = paperwork;
  }

  public PaperworkAttributeCode getCode() {
    return code;
  }

  public void setCode(final PaperworkAttributeCode code) {
    this.code = code;
  }

  public String getValue() {
    return value;
  }

  public void setValue(final String value) {
    this.value = value;
  }

  @Override
  public Map<String, Object> toJsonString() {
    final Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("id", id);
    map.put("value", value);
    map.put("code", code);
    return map;
  }

}
